/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_FVAR.h
 *
 *  Created on: 2024年9月25日
 *      Author: 64435
 */

#ifndef APP_LAYER_INC_LOS_FVAR_H_
#define APP_LAYER_INC_LOS_FVAR_H_

#include "LOS_SYS.h"

#define FROM_DEFAULT 0
#define FROM_FRAM    0XFF

//FRAM地址
#define ADDR_FR_UTC      0X00000000U
#define ADDR_FR_TKANTEN  0X00001000U
#define ADDR_FR_TKSAEN   0X00002000U
#define ADDR_FR_MMSSY    0X00003000U
#define ADDR_FR_MMSSZ    0X00004000U
#define ADDR_FR_MMGYRO   0X00005000U
#define ADDR_FR_MMSUNS   0X00006000U
#define ADDR_FR_MMMAG    0X00007000U
#define ADDR_FR_TMINV    0X00008000U
#define ADDR_FR_BOOTCNT  0X00009000U
#define ADDR_FR_MCTR     0X0000A000U
#define ADDR_FR_DELAYEN  0X0000B000U
#define ADDR_FR_DELAYDUR 0X0000C000U
#define ADDR_FR_OBC      0X0000D000U
#define ADDR_FR_DTAUTO   0X0000E000U 

#define ADDR_FR_MATSSY   0X00010000U
#define ADDR_FR_MATSSZ   0X00011000U
#define ADDR_FR_MATYH50  0X00012000U
#define ADDR_FR_MATSUNS  0X00013000U
#define ADDR_FR_MATMAGME 0X00014000U
#define ADDR_FR_MQSSY    0X00015000U
#define ADDR_FR_MQSSZ    0X00016000U
#define ADDR_FR_MGTMAX   0X00017000U
#define ADDR_FR_MAGCOMP  0X00018000U

#define ADDR_FR_TKMAXCNT 0X00020000U
#define ADDR_FR_TKDUR    0X00021000U
#define ADDR_FR_GPSAUTO  0X00022000U

//上注程序存放地址
#define ADDR_UP_PROGRAM 0X00400000U

#define MCTR_INDEX_BASE 0XCB00002A

extern uint32_t FR_UTC;
extern uint8_t FR_UTC_SEL; 
extern uint32_t FR_TKANTEN;
extern uint8_t FR_TKANTEN_SEL;
extern uint32_t FR_TKSAEN;
extern uint8_t FR_TKSAEN_SEL;
extern float FR_MCTR[20];
extern uint8_t FR_MCTR_SEL;
extern float FR_MATSSY[9];
extern uint8_t FR_MATSSY_SEL;
extern float FR_MATSSZ[9];
extern uint8_t FR_MATSSZ_SEL;
extern float FR_MATYH50[9];
extern uint8_t FR_MATYH50_SEL;
extern float FR_MATSUNS[9];
extern uint8_t FR_MATSUNS_SEL;
extern float FR_MATMAGME[9];
extern uint8_t FR_MATMAGME_SEL;
extern float FR_MQSSY[4];
extern uint8_t FR_MQSSY_SEL;
extern float FR_MQSSZ[4];
extern uint8_t FR_MQSSZ_SEL;
extern float FR_MGTMAX[6];
extern uint8_t FR_MGTMAX_SEL;
extern uint32_t FR_OBC;
extern uint8_t FR_OBC_SEL;
extern uint32_t FR_DTAUTO[2];
extern uint8_t FR_DTAUTO_SEL;

extern uint32_t FR_DELAYEN;
extern uint8_t FR_DELAYEN_SEL;
extern uint32_t FR_DELAYDUR;
extern uint8_t FR_DELAYDUR_SEL;

extern float FR_MAGCOMP[3];
extern uint8_t FR_MAGCOMP_SEL;

//烧绳相关的
extern uint32_t FR_TKMAXCNT; //烧绳次数上限
extern uint8_t FR_TKMAXCNT_SEL;
extern uint32_t FR_TKDUR;//持续时间s 
extern uint8_t FR_TKDUR_SEL;
//GPS是否自动上电
extern uint32_t FR_GPSAUTO;
extern uint8_t FR_GPSAUTO_SEL;

extern uint16_t FR_TMInvTime;
extern uint8_t FR_TMInvTime_SEL;
extern uint32_t FR_BOOTCNT;

extern uint8_t FLASH_WHERE;

void LOS_FVAR_GetAllVAR();
void LOS_FVAR_ModifyFRUTC(uint32_t UTC);
uint32_t LOS_FVAR_GetUTCFromFRAM();
void LOS_FVAR_ModifyTKANTEN(uint32_t key);
uint32_t LOS_FVAR_GetTKANTENFromFRAM();
void LOS_FVAR_ModifyTKSAEN(uint32_t key);
uint32_t LOS_FVAR_GetTKSAENFromFRAM();
void LOS_FVAR_ModifyMATSSY(float* value);
void LOS_FVAR_GetMATSSYFromFRAM();
void LOS_FVAR_ModifyMATSSZ(float* value);
void LOS_FVAR_GetMATSSZFromFRAM();
void LOS_FVAR_ModifyMATYH50(float* value);
void LOS_FVAR_GetMATYH50FromFRAM();
void LOS_FVAR_ModifyMATSUNS(float* value);
void LOS_FVAR_GetMATSUNSFromFRAM();
void LOS_FVAR_ModifyMATMAGME(float* value);
void LOS_FVAR_GetMATMAGMEFromFRAM();
void LOS_FVAR_ModifyMQSSY(float* value);
void LOS_FVAR_GetMQSSYFromFRAM();
void LOS_FVAR_ModifyMQSSZ(float* value);
void LOS_FVAR_GetMQSSZFromFRAM();
void LOS_FVAR_ModifyMGTMAX(float* value);
void LOS_FVAR_GetMGTMAXFromFRAM();
void LOS_FVAR_ModifyMCTR(float value, uint32_t index);
void LOS_FVAR_GetMCTRFromFRAM();
void LOS_FVAR_ModifyDELAYEN(uint32_t key);
uint32_t LOS_FVAR_GetDELAYENFromFRAM();
void LOS_FVAR_ModifyDELAYDUR(uint32_t time);
uint32_t LOS_FVAR_GetDELAYDURFromFRAM();
void LOS_FVAR_ModifyOBC(uint32_t obc);
uint32_t LOS_FVAR_GetOBCFromFRAM();
void LOS_FVAR_ModifyTKMAXCNT(uint32_t maxcnt);
uint32_t LOS_FVAR_GetTKMAXCNTFromFRAM();
void LOS_FVAR_ModifyTKDUR(uint32_t maxcnt);
uint32_t LOS_FVAR_GetTKDURFromFRAM();
void LOS_FVAR_ModifyGPSAUTO(uint32_t key);
uint32_t LOS_FVAR_GetGPSAUTOFromFRAM();
void LOS_FVAR_ModifyMAGCOMP(float* value);
void LOS_FVAR_GetMAGCOMPFromFRAM();
void LOS_FVAR_ModifyDTAUTO(uint32_t* value);
void LOS_FVAR_GetDTAUTOFromFRAM();

#endif /* APP_LAYER_INC_LOS_FVAR_H_ */
